export default class Gim4 extends Laya.Script {
    
    constructor() { super(); }
    private Gim4:Laya.Sprite
    private off:Laya.Sprite

    onEnable(): void {
        this.off = this.owner.parent.getChildByName("off")as Laya.Sprite
        this.Gim4 = this.owner.parent.parent.getChildByName("Gim4")as Laya.Sprite
    }

    onTriggerEnter(other: Laya.ColliderBase, self: any) {
        if (other.label == "player1" || other.label == "player2") {
            //触发开关
            Laya.Tween.to(
                this.off,
                { y: 1.5 },
                1500,
                Laya.Ease.strongInOut)
            //机关门1
            Laya.Tween.to(
                this.Gim4,
                { y: 300 },
                2500,
                Laya.Ease.strongInOut)

            //延时
            Laya.timer.once(2500, this, () => {
                Laya.Tween.to(
                    this.off,
                    { y: 1.5 },
                    1000,
                    Laya.Ease.strongInOut,
                    Laya.Handler.create(this, () => {
                        // Laya.timer.once()
                        Laya.Tween.to(
                            this.off,
                            { y: -30 },
                            1500,
                            Laya.Ease.strongInOut)
                    })
                )

                Laya.Tween.to(
                    this.Gim4,
                    { y: 300 },
                    1500,
                    Laya.Ease.strongInOut,
                    Laya.Handler.create(this, () => {
                        // Laya.timer.once()
                        Laya.Tween.to(
                            this.Gim4,
                            { y: 479 },
                            1000,
                            Laya.Ease.strongInOut)
                    })
                )
            })

        }
    }

    onDisable(): void {
    }
}